<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>GSoC2011SfM: D:/Travail/These/Determination caracteristiques camera/GSoC/SfM/src/PointsToTrackWithImage.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">GSoC2011SfM
   &#160;<span id="projectnumber">0.1</span>
   </div>
   <div id="projectbrief">Google Summer of Code 2011: Structure from motion</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">D:/Travail/These/Determination caracteristiques camera/GSoC/SfM/src/PointsToTrackWithImage.cpp</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;PointsToTrackWithImage.h&quot;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &quot;TracksOfPoints.h&quot;</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="keyword">namespace </span>OpencvSfM
<a name="l00006"></a>00006 {
<a name="l00007"></a>00007   <span class="keyword">using</span> cv::FeatureDetector;
<a name="l00008"></a>00008   <span class="keyword">using</span> cv::DescriptorExtractor;
<a name="l00009"></a>00009   <span class="keyword">using</span> cv::Ptr;
<a name="l00010"></a>00010   <span class="keyword">using</span> cv::SIFT;
<a name="l00011"></a>00011   <span class="keyword">using</span> cv::Mat;
<a name="l00012"></a>00012   <span class="keyword">using</span> std::string;
<a name="l00013"></a>00013   <span class="keyword">using</span> cv::Scalar;
<a name="l00014"></a>00014   <span class="keyword">using</span> cv::KeyPoint;
<a name="l00015"></a>00015   <span class="keyword">using</span> cv::Point;
<a name="l00016"></a>00016   <span class="keyword">using</span> std::vector;
<a name="l00017"></a>00017   <span class="keyword">using</span> cv::line;
<a name="l00018"></a>00018   <span class="keyword">using</span> cv::circle;
<a name="l00019"></a>00019 
<a name="l00020"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a515aef19b6ebd6a1cf8a945fa9e8cfad">00020</a>   <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a515aef19b6ebd6a1cf8a945fa9e8cfad">PointsToTrackWithImage::PointsToTrackWithImage</a>( <span class="keywordtype">int</span> corresponding_image,
<a name="l00021"></a>00021     cv::Mat imageToAnalyse, cv::Mat maskOfAnalyse,
<a name="l00022"></a>00022     cv::Ptr&lt;cv::FeatureDetector&gt; feature_detector,
<a name="l00023"></a>00023     cv::Ptr&lt;cv::DescriptorExtractor&gt; descriptor_detector )
<a name="l00024"></a>00024     :<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html" title="This class can be used to store informations about point and features. This is an abstract class: you...">PointsToTrack</a>( corresponding_image ),imageToAnalyse_( imageToAnalyse ),
<a name="l00025"></a>00025     maskOfAnalyse_( maskOfAnalyse ),feature_detector_( feature_detector ),
<a name="l00026"></a>00026     descriptor_detector_( descriptor_detector )
<a name="l00027"></a>00027   {
<a name="l00028"></a>00028   }
<a name="l00029"></a>00029 
<a name="l00030"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a79be2dcaea837f4f31b19bac64fd5dc9">00030</a>   <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a515aef19b6ebd6a1cf8a945fa9e8cfad">PointsToTrackWithImage::PointsToTrackWithImage</a>( <span class="keywordtype">int</span> corresponding_image,
<a name="l00031"></a>00031     cv::Mat imageToAnalyse, cv::Mat maskOfAnalyse,std::string feature_detector,
<a name="l00032"></a>00032     std::string descriptor_detector<span class="comment">/*=&quot;&quot;SIFT&quot;&quot;*/</span> )
<a name="l00033"></a>00033     :<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html" title="This class can be used to store informations about point and features. This is an abstract class: you...">PointsToTrack</a>( corresponding_image ),imageToAnalyse_( imageToAnalyse ),
<a name="l00034"></a>00034     maskOfAnalyse_( maskOfAnalyse ),
<a name="l00035"></a>00035     feature_detector_( FeatureDetector::create( feature_detector )),
<a name="l00036"></a>00036     descriptor_detector_( DescriptorExtractor::create( descriptor_detector ))
<a name="l00037"></a>00037   {
<a name="l00038"></a>00038   }
<a name="l00039"></a>00039 
<a name="l00040"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a08e85521d6884eec1d113dd81354502f">00040</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a08e85521d6884eec1d113dd81354502f">PointsToTrackWithImage::setFeatureDetector</a>( cv::Ptr&lt;cv::FeatureDetector&gt; feature_detector )
<a name="l00041"></a>00041   {
<a name="l00042"></a>00042     <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a22779db7344fed472cebc4a00ecef631" title="class which will find the points">feature_detector_</a>=feature_detector;
<a name="l00043"></a>00043   }
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a3438e554c9ef0d807ccad6799209bb50">00045</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a3438e554c9ef0d807ccad6799209bb50">PointsToTrackWithImage::setDescriptorExtractor</a>( cv::Ptr&lt;cv::DescriptorExtractor&gt; descriptor_detector )
<a name="l00046"></a>00046   {
<a name="l00047"></a>00047     <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#ac43985b39b4b99ffff25926f1e9ece66" title="class which will compute the descriptors">descriptor_detector_</a>=descriptor_detector;
<a name="l00048"></a>00048   }
<a name="l00049"></a>00049 
<a name="l00050"></a>00050   PointsToTrackWithImage::~PointsToTrackWithImage( <span class="keywordtype">void</span> )
<a name="l00051"></a>00051   {
<a name="l00052"></a>00052     <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>.release( );
<a name="l00053"></a>00053     <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a4fe39d059ba8a892abe3a1d998626806" title="Mask of analyse. Everything out of this mask is ignored.">maskOfAnalyse_</a>.release( );
<a name="l00054"></a>00054   }
<a name="l00055"></a>00055   
<a name="l00056"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#aec112b95f4c9b78bd1f8687e3bfd9225">00056</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#aec112b95f4c9b78bd1f8687e3bfd9225">PointsToTrackWithImage::getColorOfPoints</a>()
<a name="l00057"></a>00057   {
<a name="l00058"></a>00058     <span class="comment">//find color of points:</span>
<a name="l00059"></a>00059     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#ae34562f2590efe81f5ce137ef011bd00">RGB_values_</a>.clear();
<a name="l00060"></a>00060     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size_max = this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.size( );
<a name="l00061"></a>00061     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> colorFinal;
<a name="l00062"></a>00062     <span class="keywordtype">char</span> elemSize = <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>.elemSize();
<a name="l00063"></a>00063     <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;size_max; ++i )
<a name="l00064"></a>00064     {
<a name="l00065"></a>00065       <span class="comment">//as we don&#39;t know type of image, we use a different processing:</span>
<a name="l00066"></a>00066       <span class="keywordflow">switch</span> ( elemSize )
<a name="l00067"></a>00067       {
<a name="l00068"></a>00068       <span class="keywordflow">case</span> 1:<span class="comment">//char</span>
<a name="l00069"></a>00069         {
<a name="l00070"></a>00070           uchar color = <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>.at&lt;uchar&gt;( <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>[i].pt );
<a name="l00071"></a>00071           colorFinal = (<span class="keywordtype">unsigned</span> int)((((<span class="keywordtype">int</span>)color)&lt;&lt;16)|((<span class="keywordtype">int</span>)color&lt;&lt;8)|((<span class="keywordtype">int</span>)color));
<a name="l00072"></a>00072           <span class="keywordflow">break</span>;
<a name="l00073"></a>00073         }
<a name="l00074"></a>00074       <span class="keywordflow">case</span> 2:<span class="comment">//short???</span>
<a name="l00075"></a>00075         {
<a name="l00076"></a>00076           <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> color = <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>.at&lt;<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>&gt;( <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>[i].pt );
<a name="l00077"></a>00077           colorFinal = (<span class="keywordtype">unsigned</span> int)((((<span class="keywordtype">int</span>)color)&lt;&lt;16)|((int)color));
<a name="l00078"></a>00078           <span class="keywordflow">break</span>;
<a name="l00079"></a>00079         }
<a name="l00080"></a>00080       <span class="keywordflow">case</span> 3:<span class="comment">//RGB</span>
<a name="l00081"></a>00081         {
<a name="l00082"></a>00082           uchar* ptr = (<a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>.data +
<a name="l00083"></a>00083             (<a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>.step*(int)<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>[i].pt.y) +
<a name="l00084"></a>00084             (int)<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>[i].pt.x * <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>.elemSize());
<a name="l00085"></a>00085           colorFinal = (<span class="keywordtype">unsigned</span> int)((((<span class="keywordtype">int</span>)ptr[2])&lt;&lt;16)|((<span class="keywordtype">int</span>)ptr[1]&lt;&lt;8)|((<span class="keywordtype">int</span>)ptr[0]));
<a name="l00086"></a>00086           <span class="keywordflow">break</span>;
<a name="l00087"></a>00087         }
<a name="l00088"></a>00088       <span class="keywordflow">default</span>:<span class="comment">//RGBA</span>
<a name="l00089"></a>00089         {
<a name="l00090"></a>00090           colorFinal = <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>.at&lt;<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>&gt;( <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>[i].pt );
<a name="l00091"></a>00091           <span class="keywordflow">break</span>;
<a name="l00092"></a>00092         }
<a name="l00093"></a>00093       }
<a name="l00094"></a>00094       <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#ae34562f2590efe81f5ce137ef011bd00">RGB_values_</a>.push_back(colorFinal);
<a name="l00095"></a>00095     }
<a name="l00096"></a>00096   }
<a name="l00097"></a>00097 
<a name="l00098"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a6483112420b569ff0751061b2b909f87">00098</a>   <span class="keywordtype">int</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a6483112420b569ff0751061b2b909f87">PointsToTrackWithImage::impl_computeKeypoints_</a>( )
<a name="l00099"></a>00099   {
<a name="l00100"></a>00100     this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.clear();
<a name="l00101"></a>00101     <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a22779db7344fed472cebc4a00ecef631" title="class which will find the points">feature_detector_</a>-&gt;detect( <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>,this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>,<a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a4fe39d059ba8a892abe3a1d998626806" title="Mask of analyse. Everything out of this mask is ignored.">maskOfAnalyse_</a> );
<a name="l00102"></a>00102     <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#aec112b95f4c9b78bd1f8687e3bfd9225">getColorOfPoints</a>();
<a name="l00103"></a>00103     <span class="keywordflow">return</span> this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.size();
<a name="l00104"></a>00104   }
<a name="l00105"></a>00105 
<a name="l00106"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a5fad1c40831d98f6c98af064232ebbe1">00106</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#a5fad1c40831d98f6c98af064232ebbe1">PointsToTrackWithImage::impl_computeDescriptors_</a>( )
<a name="l00107"></a>00107   {
<a name="l00108"></a>00108     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a52d852bc3fa39c952405c55a8d1e378f">nb_workers_</a>++;
<a name="l00109"></a>00109     this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.release();<span class="comment">//in case some descriptors were already found...</span>
<a name="l00110"></a>00110     <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#ac43985b39b4b99ffff25926f1e9ece66" title="class which will compute the descriptors">descriptor_detector_</a>-&gt;compute( <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#adccc33e14b09ecbe0d5963b405e58d48" title="Picture from where points are detected.">imageToAnalyse_</a>,this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>,this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a> );
<a name="l00111"></a>00111     <a class="code" href="class_opencv_sf_m_1_1_points_to_track_with_image.html#aec112b95f4c9b78bd1f8687e3bfd9225">getColorOfPoints</a>();<span class="comment">//keypoints_ may have changed!</span>
<a name="l00112"></a>00112   }
<a name="l00113"></a>00113 }
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Sun Aug 21 2011 16:45:52 for GSoC2011SfM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
